Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getSelection for Safari Shadow Dom #142

Conversation

roman-kulakov
Copy link
Contributor

@roman-kulakov roman-kulakov commented Sep 21, 2022

Use custom getSelection for Safari Shadow DOM, as native method returns incorrect anchorNode and focusNode

It fixes issues described in 1310

@marijnh
Copy link
Member

marijnh commented Sep 21, 2022

This is a great start, but I don't want to include the hack where you create an object with the methods and properties of the native selection copied into it. I'd prefer to do what CodeMirror does and distinguish between selection range objects (just focusNode, focusOffset, anchorNode, anchorOffset) and selection objects that are going to have their methods called throughout the code base. Most places that need this just need the range, for which we'd add a custom getter function, and the few that do need to update the selection will have to work with two objects, the range + the native selection object.

marijnh added a commit that referenced this pull request Sep 30, 2022
FIX: Work around the five-year-old Safari bug where it won't accurately report
the selection inside shadow roots, which would break ProseMirror when put
in shadow DOM.

Issue #142
Issue ProseMirror/prosemirror#476
@marijnh
Copy link
Member

marijnh commented Sep 30, 2022

I've gone ahead and implemented what I meant in 64a96e5

@marijnh marijnh closed this Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants